package com.summer.config;

import cn.hutool.json.JSONUtil;
import com.summer.config.custom.configuration.ConfigurationBindFile;
import com.summer.config.custom.configuration.ConfigurationConfig;
import com.summer.config.custom.configuration.SpELConfig;
import com.summer.config.custom.value.ValueConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class ConfigApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(ConfigApplication.class);
        System.out.println("自定义配置开始---------------------------");
        System.out.println("@Value config result：" + context.getBean(ValueConfig.class).getTitle());
        System.out.println("@ConfigurationProperties config result: " + context.getBean(ConfigurationConfig.class).getTitle());
        System.out.println("binding config result： " + context.getBean(ConfigurationBindFile.class).getTitle());
        System.out.println("自定义配置结束---------------------------");

        System.out.println("多环境配置开始---------------------------");
        System.out.println("单文件：" + context.getBean(ValueConfig.class).getTitle());
        System.out.println("多环境配置结束---------------------------");

        System.out.println("特殊配置配置开始---------------------------");
        System.out.println("randomStr="+context.getBean(ConfigurationConfig.class).getRandomStr());
        System.out.println("randomInt="+context.getBean(ConfigurationConfig.class).getRandomInt());
        System.out.println("randomLong="+context.getBean(ConfigurationConfig.class).getRandomLong());
        System.out.println("random10="+context.getBean(ConfigurationConfig.class).getRandom10());
        System.out.println("random20="+context.getBean(ConfigurationConfig.class).getRandom20());
        System.out.println("特殊配置配置结束---------------------------");


        System.out.println("加密配置配置开始---------------------------");
        System.out.println("password="+context.getBean(ConfigurationConfig.class).getPassword());
        System.out.println("加密配置配置结束---------------------------");

    }
}
